use crate::market::*;

#[test]
fn merge_up_left_include() {
    let market = create_market!(4, [2.0f32, 2.5, 2.1, 2.3], [1.0f32, 1.5, 2., 2.2]);
    assert_eq!(vec![-1, 0, 1, 2], market.merged_index);
}

#[test]
fn merge_up_right_include() {
    let market = create_market!(4, [2.0f32, 2.5, 2.1, 2.3], [1.0f32, 1.5, 1.8, 2.2]);
    assert_eq!(vec![-1, 0, 1, 2], market.merged_index);
    assert_eq!(
        "[Stroke { index: 0, high: 2.5, low: 1.0, up: true, count: 2, days: 4, segmented: false }]",
        format!("{:?}", market.strokes())
    );
}

#[test]
fn zigzag() {
    let market = create_market!(
        40,
        [
            25.44f32, 25.34, 25.19, 25.17, 25.25, 25.28, 25.36, 25.27, 25.30, 25.34, 25.25, 25.23,
            25.11, 25.09, 25.02, 25.12, 25.13, 25.20, 25.18, 25.16, 25.16, 25.20, 25.14, 25.16,
            25.14, 25.16, 25.19, 25.21, 24.96, 24.88, 24.92, 24.89, 24.88, 24.82, 24.80, 24.81,
            24.75, 24.79, 24.54
        ],
        [
            25.21, 25.11, 25.05, 25.00, 25.08, 25.20, 25.19, 25.17, 25.21, 25.19, 25.17, 25.10,
            25.01, 24.98, 24.90, 24.97, 25.07, 25.07, 25.09, 25.10, 25.11, 25.14, 25.10, 25.05,
            25.00, 25.07, 25.13, 24.91, 24.76, 24.74, 24.79, 24.80, 24.69, 24.71, 24.72, 24.70,
            24.68, 24.48, 24.45
        ]
    );
    assert_eq_poles(
        vec![
            Pole::simple(0, Edge::PEAK),
            Pole::simple(14, Edge::TROUGH),
            Pole::simple(27, Edge::PEAK),
            Pole::simple(39, Edge::TROUGH),
        ],
        market.zigzag_with_signals().poles,
    );
}

#[test]
fn zigzag_gap() {
    let market = create_market!(
        37,
        [
            26.63, 26.62, 26.56, 26.63, 26.51, 26.42, 26.39, 26.42, 26.41, 26.39, 26.30, 26.30,
            26.25, 26.27, 26.24, 26.17, 26.16, 26.25, 26.28, 26.29, 26.23, 26.23, 26.30, 26.27,
            26.30, 26.29, 26.29, 26.23, 26.20, 26.18, 26.22, 26.07, 26.10, 26.09, 26.08, 26.11,
            26.10
        ],
        [
            26.44, 26.54, 26.48, 26.47, 26.40, 26.31, 26.29, 26.07, 26.20, 26.20, 26.20, 26.18,
            26.18, 26.22, 26.15, 26.10, 26.11, 26.10, 26.18, 26.22, 26.15, 26.18, 26.20, 26.20,
            26.17, 26.19, 26.19, 26.17, 26.17, 26.10, 26.03, 26.00, 26.03, 26.01, 26.0, 26.01,
            25.82
        ]
    );
    assert_eq_poles(
        vec![Pole::simple(1, Edge::PEAK), Pole::simple(36, Edge::TROUGH)],
        market.zigzag_with_signals().poles,
    );
}

fn assert_eq_poles(expected: Vec<Pole>, actual: Vec<Pole>) {
    let mut passed = expected.len() == actual.len();
    for i in 0..expected.len() {
        if !(expected[i].index == actual[i].index && expected[i].edge == actual[i].edge) {
            passed = false;
            break;
        }
    }
    if !passed {
        assert_eq!(expected, actual);
    }
}

#[test]
fn zigzag_dapan() {
    let market = create_market!(
        46,
        [
            2867.47, 3009.14, 3032.23, 3063.69, 3075.13, 3090.05, 3065.26, 3085.54, 3077.35,
            3102.55, 3092.43, 3123.29, 3163.14, 3157.37, 3174.27, 3130.31, 3097.20, 3043.20,
            3031.98, 2990.64, 3004.99, 2977.14, 2986.24, 2978.60, 2947.88, 2919.03, 2889.09,
            2905.15, 2867.96, 2839.28, 2756.56, 2747.74, 3087.53, 3358.59, 3674.40, 3313.98,
            3331.08, 3340.46, 3509.82, 3489.42, 3386.90, 3357.50, 3418.26, 3494.87, 3401.93,
            3418.95
        ],
        [
            2635.09, 2867.71, 2943.62, 3007.68, 3020.64, 3027.76, 2984.12, 3049.02, 3009.90,
            2995.54, 3016.52, 3080.59, 3126.17, 3116.16, 3087.79, 3085.38, 3031.04, 3011.58,
            2985.93, 2933.33, 2920.20, 2904.04, 2937.90, 2872.85, 2865.15, 2845.34, 2839.39,
            2839.34, 2815.38, 2765.64, 2703.37, 2689.70, 2731.36, 3153.70, 3187.99, 3152.82,
            3239.10, 3244.81, 3263.84, 3330.73, 3267.19, 3227.36, 3323.01, 3385.96, 3346.47,
            3348.28
        ]
    );
    assert_eq!(
        vec![
            Pole::new(0, Edge::TROUGH, 2635.09, false),
            Pole::new(12, Edge::PEAK, 3163.14, false),
            Pole::new(31, Edge::TROUGH, 2689.7, false),
            Pole::new(34, Edge::PEAK, 3674.4, false),
            Pole::new(35, Edge::TROUGH, 3152.82, false),
            Pole::new(39, Edge::PEAK, 3509.82, false),
            Pole::new(41, Edge::TROUGH, 3227.36, false),
            Pole::new(43, Edge::PEAK, 3494.87, false),
            Pole::new(44, Edge::TROUGH, 3346.47, false)
        ],
        market.zigzag_with_signals().poles
    );

}

#[test]
fn test_zigzag_dapan_monthly() {
    let market = create_market!(409,[127.61, 135.19, 134.87, 132.53, 122.2, 114.83, 137.56, 143.8, 178.43, 191.18, 218.6, 259.85, 292.75, 313.24, 364.67, 382.06, 448.94, 1429.01, 1249.58, 1215.24, 1060.36, 832.84, 713.77, 752.32, 841.02, 1198.48, 1558.95, 1339.1, 1392.62, 1380.5, 1177.91, 1009.89, 1042.47, 947.53, 934.4, 1011.76, 1044.85, 907.09, 818.57, 807.52, 705.41, 620.94, 556.9, 469.43, 787.22, 1052.94, 794.85, 743.22, 695.22, 657.45, 608.58, 648.04, 681.15, 926.41, 722.3, 723.68, 788.16, 792.54, 765.48, 736.91, 643.36, 561.36, 553.83, 606.51, 739.1, 724.97, 819.68, 894.72, 894.85, 875.52, 1038.81, 1047.39, 1258.68, 967.89, 1040.17, 1234.95, 1396.48, 1510.17, 1369.51, 1261.57, 1223.07, 1264.48, 1241.83, 1213.22, 1198.97, 1250.0, 1262.62, 1252.24, 1343.46, 1411.34, 1422.97, 1367.14, 1315.47, 1264.39, 1263.71, 1300.15, 1251.86, 1174.42, 1131.66, 1179.65, 1210.1, 1303.48, 1756.18, 1678.83, 1658.69, 1695.64, 1568.37, 1506.99, 1461.89, 1547.7, 1770.88, 1811.06, 1858.26, 1908.3, 1953.33, 2024.99, 2114.52, 2026.35, 1980.62, 2125.72, 2097.28, 2131.98, 2072.54, 2112.87, 2179.74, 2222.65, 2245.43, 2223.2, 1990.69, 1888.9, 1773.79, 1748.0, 1776.02, 1643.5, 1544.92, 1693.87, 1680.3, 1670.92, 1748.89, 1741.92, 1696.28, 1680.28, 1577.05, 1573.1, 1439.85, 1508.59, 1524.75, 1529.75, 1649.6, 1581.61, 1582.41, 1540.19, 1497.1, 1456.55, 1411.88, 1423.58, 1525.3, 1634.41, 1730.28, 1760.08, 1783.01, 1606.07, 1580.57, 1466.78, 1424.55, 1496.21, 1437.57, 1387.34, 1352.45, 1268.86, 1328.53, 1326.08, 1254.32, 1165.39, 1146.42, 1097.63, 1201.76, 1223.56, 1165.67, 1122.88, 1173.06, 1262.09, 1304.61, 1313.13, 1444.71, 1678.6, 1695.58, 1757.47, 1667.53, 1755.69, 1842.73, 2102.06, 2698.9, 2994.28, 3049.77, 3273.73, 3851.35, 4335.96, 4312.0, 4476.63, 5235.16, 5560.42, 6124.04, 6005.13, 5336.5, 5522.78, 4695.8, 4472.15, 3705.09, 3786.02, 3483.61, 2952.04, 2830.76, 2380.47, 2267.39, 2050.88, 2100.81, 2018.51, 2402.81, 2392.77, 2579.22, 2688.11, 2997.27, 3454.02, 3478.01, 3068.03, 3123.46, 3361.39, 3334.01, 3306.75, 3067.52, 3132.58, 3181.66, 2862.56, 2598.9, 2656.41, 2701.93, 2704.93, 3073.38, 3186.72, 2939.05, 2868.01, 2944.41, 3012.04, 3067.46, 2933.46, 2774.37, 2826.96, 2712.89, 2584.8, 2483.76, 2536.78, 2423.56, 2324.49, 2478.38, 2476.22, 2415.75, 2453.73, 2388.09, 2244.83, 2176.79, 2145.0, 2138.03, 2123.33, 2269.51, 2391.82, 2444.8, 2369.65, 2253.42, 2334.33, 2313.43, 2092.87, 2198.85, 2270.27, 2242.98, 2234.39, 2260.87, 2113.11, 2177.98, 2079.55, 2146.67, 2061.06, 2087.32, 2202.13, 2248.94, 2365.49, 2423.6, 2683.18, 3239.36, 3406.79, 3324.55, 3835.57, 4572.39, 4986.5, 5178.19, 4317.05, 4006.34, 3256.74, 3457.52, 3678.27, 3684.57, 3538.69, 2933.96, 3028.32, 3097.16, 3004.42, 2945.94, 3069.05, 3140.44, 3105.68, 3137.03, 3301.21, 3279.71, 3174.58, 3264.08, 3283.24, 3295.19, 3154.78, 3193.46, 3276.95, 3376.65, 3391.64, 3421.1, 3450.49, 3324.52, 3587.03, 3495.09, 3333.88, 3220.85, 3219.74, 3128.72, 2915.3, 2897.4, 2827.34, 2771.94, 2703.51, 2666.08, 2630.32, 2997.49, 3129.94, 3288.45, 2986.54, 3012.83, 3048.48, 2927.34, 3042.93, 3026.38, 3008.31, 3051.68, 3127.17, 3058.9, 3074.26, 2865.59, 2914.28, 2990.83, 3458.79, 3456.72, 3425.63, 3371.09, 3456.74, 3474.92, 3637.1, 3731.69, 3577.62, 3497.12, 3626.36, 3629.29, 3607.7, 3544.09, 3723.85, 3625.02, 3602.74, 3708.94, 3651.89, 3500.15, 3500.29, 3290.26, 3188.6, 3417.01, 3424.84, 3296.0, 3278.17, 3099.92, 3158.57, 3226.08, 3310.49, 3308.83, 3342.86, 3396.17, 3418.95, 3276.55, 3322.13, 3315.05, 3177.06, 3109.99, 3089.77, 3038.98, 2976.27, 3031.49, 3090.05, 3123.29, 3174.27, 3097.2, 3004.99, 2947.88, 3358.59, 3674.4, 3509.82, 3494.87],[95.79, 127.61, 128.06, 120.11, 113.89, 104.96, 114.89, 131.87, 143.8, 178.43, 179.8, 218.6, 259.67, 292.76, 313.24, 364.66, 381.01, 439.96, 1033.47, 961.61, 627.36, 595.42, 447.93, 386.85, 592.78, 777.16, 1196.47, 913.74, 915.59, 930.64, 859.48, 777.73, 823.0, 864.38, 774.54, 793.32, 750.46, 760.78, 749.63, 694.03, 536.34, 537.78, 458.74, 325.89, 377.97, 785.56, 546.79, 648.68, 620.47, 547.38, 524.43, 545.72, 547.21, 564.86, 625.7, 610.33, 688.65, 699.1, 693.86, 632.03, 552.84, 512.83, 518.18, 549.71, 556.23, 630.52, 636.49, 753.75, 766.7, 752.68, 852.83, 896.87, 855.84, 871.78, 870.18, 1043.92, 1222.55, 1213.24, 1154.97, 1066.04, 1116.14, 1025.13, 1087.01, 1114.13, 1119.2, 1110.08, 1189.51, 1175.55, 1240.05, 1324.72, 1323.52, 1278.3, 1043.02, 1123.63, 1191.55, 1210.84, 1125.55, 1104.5, 1064.17, 1084.15, 1087.79, 1047.83, 1259.0, 1471.5, 1546.83, 1556.74, 1452.7, 1427.35, 1341.05, 1361.21, 1583.58, 1596.07, 1746.3, 1695.53, 1884.61, 1888.24, 1980.34, 1874.21, 1896.94, 1959.72, 2024.28, 2007.7, 1893.78, 1953.72, 2081.64, 2119.89, 2157.12, 1909.29, 1795.56, 1750.76, 1514.86, 1550.46, 1593.03, 1339.2, 1476.13, 1494.83, 1575.97, 1506.54, 1455.31, 1647.27, 1624.05, 1577.53, 1488.68, 1353.14, 1348.71, 1311.68, 1474.47, 1447.01, 1473.27, 1477.25, 1483.69, 1464.87, 1406.68, 1348.22, 1334.78, 1307.4, 1398.71, 1491.69, 1585.96, 1634.71, 1572.23, 1508.65, 1376.22, 1366.5, 1310.02, 1259.43, 1289.87, 1290.99, 1264.15, 1189.21, 1187.26, 1162.03, 1135.73, 1043.28, 998.23, 1004.08, 1081.12, 1129.05, 1067.41, 1074.3, 1074.01, 1161.91, 1256.81, 1238.16, 1298.68, 1446.99, 1512.52, 1611.16, 1541.41, 1634.03, 1753.49, 1833.2, 2084.27, 2617.02, 2541.52, 2723.06, 3196.59, 3845.23, 3404.15, 3563.54, 4284.87, 5025.34, 5462.01, 4778.73, 4798.01, 4330.7, 4123.31, 3357.23, 2990.79, 3333.95, 2693.4, 2566.53, 2284.58, 1802.33, 1664.93, 1678.96, 1814.75, 1844.09, 1987.13, 2037.02, 2331.88, 2486.23, 2668.4, 2947.69, 2663.0, 2639.76, 2834.62, 2923.52, 3039.86, 2963.89, 2890.02, 2963.44, 2820.95, 2481.97, 2382.36, 2319.74, 2564.84, 2573.63, 2677.99, 2758.92, 2721.48, 2661.45, 2760.18, 2850.94, 2871.01, 2689.21, 2610.99, 2677.12, 2437.68, 2348.22, 2307.15, 2319.44, 2134.02, 2132.63, 2263.34, 2242.35, 2251.39, 2309.07, 2188.72, 2100.25, 2032.54, 1999.48, 2053.09, 1959.33, 1949.46, 2234.95, 2289.89, 2228.81, 2165.78, 2161.14, 1849.65, 1946.37, 1997.06, 2078.46, 2093.2, 2078.99, 2068.54, 1984.82, 2014.38, 1974.38, 1997.64, 1991.06, 2010.53, 2033.0, 2180.6, 2217.68, 2279.84, 2401.75, 2665.69, 3095.07, 3049.11, 3198.37, 3742.21, 4099.04, 3847.88, 3373.54, 2850.71, 2983.54, 3133.13, 3302.18, 3399.28, 2638.3, 2638.96, 2668.76, 2905.05, 2780.76, 2807.6, 2922.52, 2931.96, 2969.13, 3014.62, 3094.1, 3068.42, 3044.29, 3132.03, 3193.16, 3097.33, 3016.53, 3078.79, 3139.5, 3200.75, 3332.6, 3357.28, 3300.78, 3254.18, 3314.03, 3062.74, 3091.46, 3041.63, 3041.0, 2782.38, 2691.02, 2653.11, 2644.3, 2449.2, 2555.32, 2462.84, 2440.91, 2590.55, 2930.83, 3050.03, 2833.04, 2822.19, 2879.69, 2733.92, 2883.68, 2891.54, 2858.58, 2857.32, 2955.35, 2685.27, 2646.8, 2719.9, 2802.47, 2871.96, 2984.98, 3263.27, 3202.34, 3219.42, 3209.91, 3325.17, 3446.55, 3465.77, 3328.31, 3373.09, 3384.7, 3503.18, 3312.72, 3367.64, 3514.67, 3502.8, 3448.44, 3558.69, 3356.56, 3390.46, 3023.3, 2863.65, 2957.4, 3160.04, 3226.23, 3155.19, 3021.93, 2885.09, 2896.76, 3031.54, 3073.05, 3223.26, 3216.99, 3229.45, 3168.57, 3144.25, 3151.13, 3053.04, 3078.8, 2923.51, 3009.12, 2882.02, 2724.16, 2635.09, 2984.12, 2995.54, 3085.38, 2933.33, 2865.15, 2815.38, 2689.7, 3152.82, 3227.36, 3323.01]);
    let zigzag = market.zigzag_with_signals();
    println!("zigzag: {:?}", zigzag);
    assert!(zigzag.poles.len() > 1);
}

#[test]
fn test_average_idx() {
    let market = create_market!(420,[18.77, 18.85, 19.01, 19.2, 19.14, 19.31, 19.4, 19.47, 19.61, 19.4, 19.28, 19.28, 19.25, 19.42, 19.4, 19.41, 19.48, 19.28, 19.31, 19.32, 19.38, 19.46, 19.44, 19.46, 19.6, 19.51, 19.41, 19.37, 19.34, 19.35, 19.37, 19.39, 19.4, 19.29, 19.31, 19.28, 19.46, 19.57, 19.68, 19.77, 19.88, 19.77, 19.72, 19.66, 19.69, 19.84, 19.85, 19.85, 19.83, 19.86, 19.86, 19.94, 20.04, 19.98, 20.05, 19.97, 19.81, 19.83, 19.77, 19.76, 19.75, 19.73, 19.67, 19.66, 19.47, 19.45, 19.46, 19.6, 19.63, 19.75, 19.84, 19.87, 19.79, 19.78, 19.91, 19.91, 19.78, 19.56, 19.47, 19.48, 19.51, 19.31, 19.31, 19.25, 19.38, 19.47, 19.45, 19.48, 19.49, 19.42, 19.46, 19.57, 19.81, 20.02, 20.0, 20.14, 20.27, 20.27, 20.25, 20.3, 20.6, 20.71, 20.6, 20.57, 20.61, 20.65, 20.65, 20.52, 20.64, 20.69, 20.61, 20.67, 20.72, 20.76, 20.79, 20.89, 21.27, 21.32, 21.38, 21.3, 21.21, 21.23, 21.14, 21.08, 21.28, 21.34, 21.31, 21.45, 21.55, 21.54, 21.48, 21.61, 21.75, 21.75, 21.63, 21.63, 21.67, 21.51, 21.44, 21.32, 21.4, 21.28, 21.14, 21.17, 21.14, 21.23, 21.37, 21.43, 21.4, 21.38, 21.24, 21.29, 21.23, 21.13, 21.05, 20.95, 20.85, 20.91, 20.82, 20.83, 20.84, 20.84, 20.63, 20.49, 20.43, 20.26, 20.19, 20.18, 20.19, 20.05, 19.86, 19.8, 20.0, 19.96, 19.83, 19.88, 19.76, 19.75, 20.17, 20.24, 20.39, 20.45, 20.44, 20.57, 20.69, 20.66, 20.58, 20.64, 20.77, 20.74, 20.79, 20.76, 20.83, 20.79, 20.69, 20.73, 20.81, 20.76, 20.73, 20.75, 20.58, 20.47, 20.38, 20.35, 20.09, 20.04, 20.08, 20.01, 20.06, 19.95, 19.94, 20.12, 20.29, 20.23, 20.16, 20.16, 20.16, 20.11, 20.07, 20.01, 19.77, 19.76, 19.99, 19.99, 20.01, 19.94, 20.14, 20.3, 20.44, 20.44, 20.54, 20.55, 20.42, 20.5, 20.45, 20.38, 20.36, 20.3, 20.37, 20.74, 20.83, 20.74, 20.75, 20.67, 20.87, 20.95, 20.98, 20.96, 20.98, 21.02, 20.99, 21.0, 21.04, 20.95, 20.99, 21.03, 21.04, 20.9, 21.07, 20.99, 20.98, 20.94, 20.96, 21.03, 20.94, 20.87, 20.87, 20.7, 20.81, 20.77, 20.92, 20.96, 20.94, 20.97, 20.9, 20.91, 20.95, 20.82, 21.0, 21.17, 21.15, 21.07, 21.12, 21.1, 21.11, 21.09, 21.1, 21.06, 20.88, 20.88, 20.91, 20.97, 21.65, 21.52, 21.5, 21.4, 21.44, 21.41, 21.35, 21.3, 21.21, 21.24, 21.31, 21.32, 21.3, 21.28, 21.33, 21.33, 21.39, 21.37, 21.31, 21.43, 21.48, 21.43, 21.5, 21.5, 21.41, 21.32, 21.37, 21.33, 21.3, 21.41, 21.4, 21.27, 21.16, 21.09, 21.09, 21.03, 21.03, 20.96, 20.97, 20.89, 20.85, 20.77, 20.6, 20.54, 20.49, 20.57, 20.42, 20.37, 20.39, 20.43, 20.51, 20.5, 20.63, 20.62, 20.53, 20.49, 20.45, 20.37, 20.32, 20.29, 20.5, 20.6, 20.62, 20.62, 20.86, 20.9, 20.95, 21.03, 21.07, 20.96, 20.89, 20.91, 20.87, 20.62, 20.61, 20.56, 20.44, 20.47, 20.27, 20.27, 20.41, 20.39, 20.26, 20.26, 20.35, 20.3, 20.27, 20.42, 20.39, 20.15, 20.12, 20.05, 20.14, 20.22, 20.2, 20.1, 20.33, 20.39, 20.4, 20.46, 20.49, 20.43, 20.41, 20.42, 20.54, 20.58, 20.58, 20.66, 20.62, 20.57, 20.47, 20.44, 20.37, 20.4, 20.37, 20.33, 20.24, 20.26, 20.24, 20.27, 20.26, 20.13, 20.12, 20.01, 20.0, 19.89, 19.84, 19.86],[18.26, 18.58, 18.76, 18.78, 18.91, 18.95, 19.22, 19.23, 19.3, 19.19, 19.15, 19.2, 19.04, 19.19, 19.25, 19.28, 19.22, 19.02, 19.14, 19.2, 19.12, 19.31, 19.33, 19.34, 19.45, 19.39, 19.22, 19.23, 19.16, 19.13, 19.28, 19.31, 19.21, 19.2, 19.22, 19.23, 19.35, 19.38, 19.52, 19.62, 19.72, 19.66, 19.56, 19.58, 19.56, 19.68, 19.77, 19.71, 19.76, 19.8, 19.79, 19.83, 19.75, 19.84, 19.97, 19.81, 19.69, 19.67, 19.65, 19.63, 19.49, 19.58, 19.54, 19.47, 19.32, 19.34, 19.34, 19.46, 19.45, 19.6, 19.7, 19.73, 19.65, 19.65, 19.77, 19.71, 19.49, 19.11, 19.34, 19.33, 19.27, 19.21, 19.18, 19.09, 19.07, 19.36, 19.35, 19.41, 19.36, 19.35, 19.4, 19.45, 19.56, 19.79, 19.87, 19.97, 20.15, 20.16, 20.12, 20.25, 20.26, 20.51, 20.45, 20.26, 20.44, 20.44, 20.52, 20.28, 20.27, 20.46, 20.44, 20.56, 20.63, 20.63, 20.68, 20.77, 21.05, 21.19, 21.11, 21.04, 20.97, 21.12, 20.99, 20.96, 20.95, 21.14, 21.09, 21.3, 21.45, 21.42, 21.36, 21.48, 21.56, 21.59, 21.5, 21.51, 21.47, 21.35, 21.17, 21.11, 21.19, 20.99, 20.91, 21.09, 21.05, 21.03, 21.23, 21.27, 21.25, 21.18, 21.12, 21.2, 21.06, 21.03, 20.85, 20.74, 20.6, 20.73, 20.71, 20.57, 20.67, 20.63, 20.43, 20.29, 19.74, 19.84, 20.03, 20.03, 20.05, 19.82, 19.64, 19.6, 19.75, 19.75, 19.67, 19.72, 19.68, 19.55, 19.75, 20.09, 20.16, 20.31, 20.3, 20.44, 20.54, 20.47, 20.45, 20.55, 20.55, 20.59, 20.71, 20.68, 20.7, 20.69, 20.51, 20.65, 20.66, 20.67, 20.63, 20.58, 20.34, 20.35, 20.24, 19.96, 19.76, 19.79, 19.94, 19.92, 19.9, 19.79, 19.71, 19.86, 20.05, 20.07, 20.04, 20.05, 20.03, 19.94, 19.94, 19.89, 19.43, 19.42, 19.68, 19.86, 19.87, 19.85, 19.87, 20.14, 20.3, 20.28, 20.42, 20.33, 20.35, 20.41, 20.38, 20.21, 20.21, 20.13, 20.18, 20.37, 20.64, 20.64, 20.56, 20.59, 20.6, 20.81, 20.87, 20.86, 20.88, 20.95, 20.88, 20.86, 20.91, 20.81, 20.88, 20.94, 20.9, 20.78, 20.88, 20.94, 20.84, 20.82, 20.84, 20.89, 20.87, 20.79, 20.6, 20.58, 20.62, 20.67, 20.75, 20.85, 20.87, 20.88, 20.78, 20.81, 20.73, 20.72, 20.81, 21.0, 21.02, 21.0, 21.06, 21.03, 20.97, 20.95, 21.01, 20.85, 20.79, 20.77, 20.82, 20.88, 21.32, 21.37, 21.37, 21.31, 21.38, 21.32, 21.23, 21.11, 21.09, 21.11, 21.21, 21.19, 21.23, 21.16, 21.26, 21.28, 21.3, 21.26, 21.17, 21.22, 21.37, 21.38, 21.39, 21.45, 21.26, 21.24, 21.29, 21.24, 21.2, 21.23, 21.26, 21.12, 21.02, 21.01, 20.99, 20.98, 20.95, 20.9, 20.84, 20.79, 20.56, 20.59, 20.46, 20.43, 20.31, 20.42, 20.33, 20.27, 20.14, 20.28, 20.43, 20.4, 20.49, 20.52, 20.48, 20.39, 20.22, 20.22, 20.21, 20.22, 20.29, 20.49, 20.5, 20.54, 20.54, 20.82, 20.83, 20.95, 20.94, 20.86, 20.79, 20.83, 20.62, 20.5, 20.53, 20.4, 20.33, 20.27, 20.14, 20.16, 20.21, 20.25, 20.05, 20.11, 20.18, 20.26, 20.21, 20.26, 20.03, 19.95, 19.99, 19.93, 20.04, 20.12, 20.08, 20.01, 20.05, 20.3, 20.35, 20.39, 20.41, 20.34, 20.33, 20.37, 20.33, 20.5, 20.52, 20.54, 20.53, 20.47, 20.31, 20.36, 20.06, 20.32, 20.29, 20.2, 20.16, 20.19, 20.18, 20.19, 20.01, 20.02, 19.95, 19.9, 19.86, 19.8, 19.7, 19.69]);
    let zigzag = market.zigzag_with_signals();
    println!("Zigzag: {:?}", zigzag);
}

#[test]
fn pivot_jcqd_weekly() {
    let market = create_market!(322,[13.24, 18.13, 16.33, 13.3, 15.11, 15.8, 15.52, 15.8, 15.8, 14.46, 13.9, 13.41, 13.16, 13.47, 12.49, 13.31, 13.47, 15.41, 18.58, 20.27, 22.24, 24.07, 24.03, 25.16, 25.83, 24.07, 24.23, 22.68, 23.23, 23.67, 23.59, 21.68, 19.71, 18.74, 17.91, 17.33, 16.51, 17.94, 18.29, 18.91, 17.64, 15.51, 15.59, 15.54, 15.01, 16.97, 17.68, 18.09, 17.53, 17.93, 17.47, 16.96, 15.06, 16.23, 16.51, 16.52, 17.91, 19.73, 18.42, 18.39, 19.87, 20.39, 22.51, 22.47, 21.91, 22.18, 23.71, 25.06, 25.61, 24.36, 28.29, 28.34, 29.37, 25.64, 23.61, 21.0, 20.48, 19.87, 22.73, 24.57, 23.91, 24.55, 25.79, 26.44, 28.66, 26.54, 30.56, 32.23, 34.77, 33.62, 35.7, 40.12, 39.47, 42.31, 41.49, 43.14, 48.71, 48.04, 51.56, 57.41, 55.84, 55.08, 54.24, 47.49, 47.86, 52.28, 51.18, 48.59, 51.92, 55.48, 50.39, 48.91, 46.71, 47.49, 49.96, 49.42, 54.62, 59.74, 58.05, 71.21, 70.42, 69.69, 66.39, 64.56, 61.29, 58.63, 52.27, 53.12, 50.65, 52.24, 51.27, 46.42, 46.97, 45.11, 43.04, 43.71, 47.26, 48.05, 51.46, 50.1, 45.5, 48.53, 50.8, 49.28, 53.35, 50.54, 49.64, 54.09, 53.03, 52.35, 53.58, 50.83, 46.25, 44.18, 41.73, 43.72, 45.44, 47.53, 45.63, 46.68, 51.15, 55.74, 59.35, 55.15, 55.73, 54.65, 55.6, 52.79, 52.9, 49.35, 46.68, 43.83, 45.15, 42.51, 38.63, 38.65, 37.21, 33.02, 30.5, 34.31, 30.15, 28.48, 26.88, 26.12, 26.44, 29.93, 32.92, 32.5, 31.33, 31.32, 34.84, 35.63, 36.95, 35.34, 34.9, 32.45, 33.16, 33.16, 33.85, 33.7, 33.34, 31.48, 31.07, 29.46, 28.1, 27.07, 27.4, 26.97, 28.07, 28.07, 27.48, 28.85, 30.83, 29.58, 27.46, 27.65, 27.02, 25.54, 25.68, 26.3, 26.24, 25.97, 27.06, 28.73, 30.77, 30.25, 29.39, 28.16, 26.56, 24.57, 24.54, 24.67, 24.51, 24.3, 22.26, 18.97, 19.1, 18.9, 19.23, 21.03, 18.77, 18.85, 21.04, 21.43, 23.24, 20.82, 19.97, 19.25, 20.02, 20.29, 19.0, 18.12, 18.17, 18.25, 18.08, 17.91, 18.69, 19.69, 20.71, 20.71, 22.38, 21.79, 21.41, 21.21, 22.35, 20.1, 19.82, 19.67, 19.98, 20.22, 21.01, 20.5, 18.35, 17.71, 16.37, 16.66, 17.62, 17.74, 17.85, 18.48, 17.75, 19.17, 20.57, 21.92, 22.42, 21.75, 22.76, 21.76, 20.7, 19.47, 19.2, 19.3, 20.18, 20.85, 21.0, 20.83, 20.45, 18.24, 17.73, 17.25, 16.93, 16.64, 16.5, 16.31, 15.56, 15.77, 17.53, 19.2, 21.02, 19.5, 20.89, 21.17, 22.07, 23.9, 22.85, 22.59, 28.5, 29.88, 26.29, 27.0, 26.28, 24.29],[10.77, 14.71, 12.69, 11.55, 11.79, 12.94, 12.85, 14.42, 13.82, 12.43, 12.87, 12.43, 12.54, 12.18, 11.72, 12.14, 12.33, 13.5, 14.42, 18.61, 19.17, 20.7, 21.37, 21.72, 23.3, 22.59, 21.8, 21.19, 20.76, 21.68, 22.03, 18.18, 18.02, 16.42, 16.42, 14.98, 15.03, 15.33, 16.69, 16.68, 15.49, 14.26, 13.51, 14.16, 13.6, 13.55, 16.04, 15.49, 15.26, 16.91, 16.16, 14.63, 14.04, 14.52, 15.42, 14.92, 15.26, 17.46, 16.78, 17.33, 17.48, 18.61, 19.22, 21.2, 20.46, 20.33, 20.75, 22.13, 23.3, 21.48, 23.07, 26.03, 23.33, 23.25, 19.5, 17.91, 18.2, 18.38, 20.03, 21.67, 21.26, 20.74, 23.58, 24.32, 24.88, 24.58, 25.31, 29.29, 30.79, 32.05, 32.18, 32.5, 34.86, 37.28, 38.01, 39.09, 41.99, 45.71, 46.29, 50.7, 48.71, 49.22, 46.89, 44.3, 46.5, 46.61, 43.34, 43.07, 45.36, 49.64, 46.66, 44.54, 42.38, 43.71, 43.4, 45.71, 46.31, 53.06, 52.8, 55.86, 63.26, 61.3, 59.64, 58.69, 54.78, 48.36, 46.17, 47.78, 45.7, 47.78, 43.78, 42.04, 40.78, 42.41, 40.34, 39.9, 42.69, 44.14, 45.1, 44.35, 41.8, 42.16, 47.03, 44.13, 43.55, 46.77, 44.85, 48.07, 47.85, 47.51, 48.07, 43.95, 42.65, 40.86, 38.2, 39.49, 42.51, 42.93, 42.15, 41.95, 44.92, 48.55, 51.85, 51.47, 48.95, 49.71, 51.6, 49.85, 48.1, 44.93, 42.92, 41.25, 40.55, 36.53, 35.87, 36.05, 32.35, 28.15, 26.07, 28.85, 27.85, 26.35, 24.56, 22.9, 21.72, 26.45, 28.36, 29.26, 28.96, 28.64, 30.73, 31.35, 33.78, 32.15, 31.14, 29.47, 30.89, 30.48, 30.87, 31.39, 31.06, 28.07, 27.57, 27.08, 25.48, 24.41, 24.35, 23.67, 26.07, 24.07, 24.02, 26.03, 28.45, 26.97, 26.33, 25.87, 25.24, 24.18, 24.47, 24.72, 25.12, 25.07, 25.63, 26.15, 28.47, 28.62, 27.85, 26.38, 23.72, 22.9, 23.63, 23.37, 23.55, 22.08, 18.34, 18.12, 18.07, 18.13, 17.94, 17.72, 16.67, 16.77, 18.36, 18.89, 20.27, 19.74, 18.59, 18.44, 18.84, 19.04, 17.45, 16.79, 16.62, 17.66, 17.33, 16.92, 17.19, 17.47, 19.22, 18.7, 19.41, 20.03, 19.89, 19.83, 19.78, 18.98, 18.77, 18.83, 18.27, 19.41, 19.59, 18.15, 16.68, 13.68, 12.7, 15.68, 15.96, 16.99, 17.23, 17.51, 16.36, 17.04, 18.8, 19.34, 20.63, 21.04, 21.25, 20.09, 19.02, 18.81, 18.14, 17.93, 18.85, 19.18, 18.17, 18.61, 17.6, 16.36, 16.59, 16.16, 16.22, 15.56, 15.17, 15.44, 14.85, 14.66, 15.2, 17.9, 17.81, 17.35, 18.79, 18.95, 19.0, 21.22, 20.8, 19.94, 23.69, 26.0, 24.64, 24.37, 23.08, 22.9]);
    let zigzag = market.zigzag_with_signals();
    println!("pivots: {:?}", zigzag.pivots);
    println!("signals: {:?}", zigzag.signals);
}

#[test]
fn dapan_30_minutes() {
    let market = create_market!(280,[3314.7, 3309.17, 3316.16, 3350.84, 3357.5, 3344.15, 3343.86, 3333.36, 3352.39, 3356.34, 3361.51, 3360.9, 3362.72, 3369.3, 3364.63, 3364.22, 3369.12, 3358.34, 3366.41, 3372.68, 3371.72, 3366.79, 3386.62, 3382.17, 3376.58, 3374.72, 3382.22, 3388.02, 3382.69, 3380.87, 3382.33, 3365.13, 3369.43, 3363.23, 3374.92, 3375.62, 3373.96, 3377.05, 3370.06, 3368.86, 3376.88, 3377.53, 3405.19, 3418.26, 3411.12, 3405.85, 3410.27, 3409.95, 3411.13, 3425.4, 3426.65, 3417.37, 3400.16, 3399.76, 3398.29, 3406.45, 3494.87, 3467.63, 3462.98, 3456.18, 3460.24, 3446.53, 3441.31, 3436.48, 3433.06, 3437.69, 3437.81, 3435.78, 3430.82, 3430.55, 3435.01, 3433.38, 3436.67, 3443.62, 3438.54, 3454.89, 3460.84, 3458.17, 3464.12, 3461.52, 3442.93, 3419.87, 3419.38, 3415.59, 3417.1, 3425.83, 3424.91, 3408.34, 3401.93, 3397.01, 3397.91, 3395.61, 3400.16, 3392.74, 3393.6, 3386.4, 3393.63, 3396.21, 3383.75, 3377.14, 3381.32, 3389.3, 3375.09, 3368.07, 3392.9, 3393.59, 3389.72, 3385.64, 3396.46, 3395.54, 3388.17, 3385.35, 3374.18, 3367.05, 3363.37, 3361.21, 3371.57, 3377.09, 3377.53, 3376.99, 3379.33, 3380.96, 3383.09, 3388.74, 3390.62, 3376.96, 3371.02, 3372.38, 3384.99, 3372.4, 3381.97, 3383.8, 3378.16, 3380.74, 3364.04, 3359.95, 3369.95, 3380.34, 3379.45, 3380.05, 3383.78, 3383.3, 3383.79, 3394.9, 3406.21, 3397.13, 3396.75, 3387.02, 3390.63, 3397.0, 3397.58, 3393.35, 3393.24, 3395.49, 3397.79, 3398.28, 3401.1, 3396.76, 3399.18, 3400.66, 3403.34, 3397.7, 3401.89, 3418.95, 3412.05, 3411.23, 3404.71, 3405.83, 3412.84, 3409.49, 3408.73, 3408.77, 3403.95, 3405.5, 3410.86, 3411.99, 3413.45, 3405.33, 3404.87, 3393.69, 3396.41, 3383.12, 3379.02, 3375.37, 3351.72, 3332.56, 3330.15, 3327.6, 3316.43, 3300.28, 3284.84, 3271.58, 3273.57, 3266.48, 3269.06, 3257.71, 3247.66, 3251.33, 3232.4, 3225.98, 3211.29, 3219.12, 3218.88, 3219.49, 3210.06, 3195.79, 3209.46, 3208.16, 3213.34, 3212.28, 3207.2, 3200.7, 3209.29, 3217.25, 3226.89, 3230.85, 3228.16, 3228.81, 3219.12, 3203.07, 3193.12, 3233.76, 3246.29, 3233.52, 3224.49, 3227.63, 3224.69, 3228.97, 3226.33, 3224.87, 3220.49, 3222.43, 3220.11, 3206.12, 3215.1, 3207.09, 3202.28, 3201.82, 3196.0, 3185.21, 3165.73, 3162.59, 3172.7, 3164.46, 3160.78, 3164.47, 3164.54, 3160.76, 3195.65, 3205.21, 3215.26, 3229.99, 3227.6, 3236.15, 3245.22, 3240.94, 3245.9, 3239.95, 3239.76, 3243.22, 3234.28, 3231.77, 3230.81, 3228.44, 3265.28, 3256.17, 3254.58, 3241.69, 3235.32, 3233.21, 3238.25, 3237.31, 3234.32, 3246.21, 3237.35, 3249.27, 3255.63, 3256.51, 3251.38, 3246.88],[3294.42, 3293.69, 3297.14, 3315.56, 3336.63, 3333.6, 3318.78, 3323.51, 3323.01, 3343.85, 3347.74, 3346.66, 3350.9, 3358.82, 3352.28, 3350.03, 3352.69, 3348.37, 3352.07, 3360.69, 3361.35, 3352.41, 3366.71, 3375.65, 3362.4, 3365.6, 3370.88, 3374.47, 3374.83, 3372.2, 3353.84, 3352.94, 3353.06, 3353.5, 3359.39, 3363.03, 3365.03, 3367.41, 3357.3, 3360.01, 3364.21, 3365.5, 3376.42, 3401.06, 3399.83, 3396.77, 3403.12, 3402.58, 3397.98, 3406.02, 3414.09, 3390.62, 3385.96, 3386.03, 3390.38, 3397.37, 3446.79, 3447.7, 3445.99, 3440.36, 3443.48, 3437.1, 3427.77, 3417.77, 3416.09, 3425.1, 3429.16, 3421.66, 3424.48, 3420.16, 3425.98, 3428.52, 3427.45, 3433.49, 3425.98, 3428.45, 3446.52, 3449.45, 3451.7, 3456.1, 3419.69, 3407.31, 3405.74, 3406.5, 3403.53, 3405.72, 3407.17, 3390.75, 3388.8, 3386.34, 3385.02, 3389.24, 3388.49, 3386.36, 3380.64, 3376.54, 3376.02, 3382.34, 3368.4, 3365.53, 3359.43, 3374.78, 3363.26, 3357.77, 3371.3, 3381.51, 3380.49, 3378.16, 3383.48, 3384.26, 3381.34, 3375.78, 3346.47, 3353.58, 3352.68, 3355.47, 3353.26, 3367.43, 3364.09, 3366.7, 3362.82, 3371.68, 3373.23, 3380.95, 3375.47, 3369.8, 3362.85, 3365.1, 3367.56, 3361.83, 3368.98, 3371.01, 3366.28, 3363.08, 3348.28, 3350.17, 3352.95, 3367.49, 3362.59, 3368.23, 3367.83, 3377.54, 3376.16, 3383.05, 3386.08, 3386.07, 3384.41, 3374.01, 3377.92, 3388.69, 3386.97, 3381.9, 3380.25, 3384.25, 3389.86, 3392.78, 3394.17, 3390.83, 3390.9, 3395.31, 3392.8, 3388.32, 3393.91, 3399.02, 3405.98, 3402.3, 3393.17, 3397.42, 3395.4, 3403.78, 3401.77, 3394.96, 3395.75, 3400.3, 3404.7, 3403.59, 3402.23, 3398.26, 3389.76, 3373.77, 3380.76, 3373.83, 3355.43, 3351.76, 3330.27, 3310.86, 3316.14, 3314.85, 3292.57, 3273.29, 3255.39, 3242.09, 3243.34, 3237.66, 3248.47, 3247.32, 3233.85, 3226.97, 3205.78, 3207.25, 3191.54, 3185.97, 3203.0, 3198.35, 3191.86, 3185.46, 3191.42, 3188.69, 3194.4, 3202.09, 3190.46, 3190.5, 3191.17, 3204.13, 3204.78, 3220.32, 3213.56, 3214.24, 3201.13, 3180.93, 3175.72, 3188.03, 3226.17, 3218.14, 3209.64, 3213.81, 3217.28, 3218.14, 3218.12, 3213.22, 3205.91, 3211.39, 3198.49, 3192.54, 3201.35, 3197.22, 3190.23, 3193.66, 3182.27, 3168.52, 3146.86, 3140.98, 3153.69, 3154.37, 3149.58, 3151.07, 3148.71, 3147.46, 3159.43, 3184.56, 3195.27, 3214.49, 3214.37, 3223.83, 3232.46, 3223.95, 3229.91, 3229.12, 3232.59, 3231.62, 3227.53, 3225.26, 3223.03, 3222.24, 3239.03, 3247.86, 3233.55, 3227.6, 3217.1, 3221.96, 3227.21, 3228.62, 3219.77, 3224.93, 3231.07, 3229.97, 3242.15, 3243.44, 3243.46, 3240.06]);
    let zigzag = market.zigzag_with_signals();
    println!("Zigzag: {:?}", zigzag);

}

#[test]
fn sample() {
    let market = create_market!(840,[2878.47, 2877.84, 2878.25, 2880.53, 2886.59, 2886.94, 2878.28, 2874.74, 2868.72, 2859.73, 2873.08, 2886.4, 2881.24, 2876.37, 2876.28, 2873.71, 2887.85, 2880.05, 2882.58, 2883.12, 2873.31, 2875.04, 2869.81, 2870.89, 2863.6, 2866.84, 2869.27, 2863.09, 2868.44, 2862.95, 2860.54, 2858.46, 2863.54, 2865.67, 2861.54, 2862.33, 2856.75, 2857.9, 2855.51, 2867.95, 2866.24, 2859.73, 2864.28, 2861.72, 2857.91, 2858.65, 2857.51, 2858.42, 2863.96, 2886.03, 2889.09, 2882.91, 2880.98, 2871.71, 2869.96, 2880.54, 2888.42, 2888.68, 2885.15, 2881.24, 2884.07, 2879.6, 2882.94, 2882.19, 2903.91, 2905.15, 2895.87, 2896.07, 2895.87, 2895.27, 2895.86, 2895.86, 2896.52, 2880.34, 2873.09, 2869.76, 2867.49, 2867.52, 2865.39, 2869.08, 2861.93, 2863.89, 2863.03, 2858.72, 2856.44, 2859.45, 2860.34, 2860.1, 2861.61, 2855.45, 2859.29, 2858.26, 2858.65, 2855.84, 2854.22, 2851.52, 2856.08, 2845.27, 2843.19, 2860.73, 2856.68, 2851.19, 2849.62, 2856.32, 2860.65, 2853.47, 2849.84, 2852.8, 2852.21, 2848.77, 2852.99, 2856.45, 2853.78, 2852.82, 2853.12, 2848.99, 2846.83, 2850.53, 2851.65, 2851.86, 2852.56, 2844.47, 2849.27, 2847.5, 2842.23, 2837.46, 2835.43, 2839.93, 2831.11, 2824.58, 2830.63, 2826.45, 2829.46, 2829.12, 2830.56, 2831.43, 2842.83, 2840.63, 2856.78, 2861.31, 2864.09, 2867.96, 2861.59, 2852.53, 2839.28, 2837.48, 2828.32, 2827.78, 2826.9, 2828.14, 2827.13, 2819.35, 2814.9, 2810.81, 2807.33, 2804.8, 2801.11, 2802.72, 2804.72, 2804.77, 2792.96, 2788.06, 2797.68, 2800.61, 2789.26, 2790.23, 2790.45, 2788.83, 2796.02, 2788.69, 2795.57, 2787.57, 2786.6, 2783.96, 2785.85, 2791.54, 2804.09, 2803.64, 2799.34, 2793.82, 2784.04, 2780.12, 2778.35, 2776.14, 2756.56, 2747.54, 2742.9, 2742.94, 2741.0, 2739.61, 2734.18, 2740.14, 2742.51, 2732.08, 2733.84, 2728.49, 2735.36, 2733.32, 2750.12, 2746.14, 2732.73, 2727.08, 2729.32, 2723.9, 2724.16, 2719.56, 2720.17, 2724.82, 2734.68, 2733.16, 2726.7, 2720.82, 2731.89, 2730.7, 2725.77, 2724.82, 2728.78, 2728.09, 2722.58, 2716.21, 2718.98, 2719.51, 2713.39, 2709.75, 2715.21, 2706.68, 2708.37, 2705.21, 2702.54, 2722.16, 2724.11, 2717.9, 2725.86, 2744.91, 2747.74, 2734.37, 2742.21, 2738.83, 2737.64, 2738.93, 2734.47, 2736.17, 2735.3, 2734.2, 2729.75, 2724.16, 2731.12, 2741.16, 2752.04, 2749.92, 2754.6, 2760.48, 2756.93, 2755.85, 2749.87, 2751.81, 2780.96, 2770.71, 2793.19, 2814.86, 2849.13, 2855.75, 2852.95, 2863.15, 2943.62, 2952.45, 2941.14, 2926.78, 2922.86, 2911.87, 2909.27, 2903.82, 2918.45, 2927.97, 2928.65, 2919.07, 2955.9, 2971.27, 2986.3, 3000.95, 3067.41, 3046.85, 3031.71, 3065.75, 3082.71, 3081.95, 3077.24, 3087.53, 3272.09, 3226.03, 3254.87, 3263.77, 3311.83, 3336.17, 3358.59, 3336.5, 3674.4, 3555.75, 3484.08, 3532.5, 3518.28, 3460.36, 3471.49, 3491.0, 3437.16, 3386.63, 3348.5, 3320.42, 3368.16, 3405.88, 3353.5, 3328.2, 3327.75, 3287.31, 3328.89, 3376.63, 3379.81, 3360.74, 3334.92, 3324.68, 3297.75, 3278.67, 3270.15, 3272.81, 3265.37, 3254.35, 3231.85, 3217.76, 3269.91, 3230.95, 3242.78, 3271.86, 3294.62, 3292.36, 3278.23, 3284.59, 3275.39, 3285.21, 3276.55, 3270.36, 3267.87, 3247.27, 3241.37, 3227.33, 3213.89, 3217.47, 3213.56, 3236.85, 3227.5, 3208.75, 3203.76, 3214.02, 3235.24, 3241.57, 3212.29, 3218.51, 3216.4, 3208.52, 3202.37, 3184.78, 3178.76, 3177.07, 3211.49, 3195.51, 3252.13, 3263.61, 3284.07, 3313.98, 3277.92, 3284.28, 3290.59, 3290.8, 3300.66, 3279.42, 3270.51, 3271.83, 3281.93, 3283.03, 3284.96, 3285.49, 3294.96, 3280.84, 3285.54, 3286.83, 3294.14, 3312.97, 3310.5, 3316.73, 3331.08, 3322.9, 3312.68, 3308.48, 3292.94, 3289.04, 3289.97, 3288.33, 3286.55, 3275.79, 3283.4, 3280.74, 3290.47, 3298.2, 3297.84, 3308.0, 3319.36, 3310.4, 3302.75, 3301.42, 3300.46, 3312.73, 3311.48, 3311.29, 3308.13, 3315.35, 3314.57, 3322.2, 3340.46, 3327.2, 3328.9, 3322.09, 3300.5, 3302.76, 3297.78, 3296.69, 3291.15, 3291.68, 3283.42, 3283.17, 3258.05, 3258.75, 3263.25, 3273.01, 3269.76, 3282.03, 3295.74, 3293.17, 3281.61, 3275.76, 3289.66, 3288.93, 3298.1, 3295.63, 3303.26, 3300.1, 3305.32, 3289.26, 3287.43, 3284.59, 3281.17, 3291.25, 3287.27, 3290.86, 3290.68, 3289.84, 3297.19, 3310.21, 3334.71, 3362.72, 3353.06, 3370.32, 3383.41, 3382.0, 3381.29, 3386.99, 3400.57, 3421.0, 3407.36, 3402.44, 3393.85, 3404.28, 3405.97, 3391.07, 3395.64, 3405.89, 3411.74, 3413.66, 3427.59, 3447.82, 3453.93, 3470.66, 3509.82, 3498.9, 3494.95, 3480.07, 3476.37, 3478.06, 3467.56, 3459.37, 3446.92, 3451.98, 3436.9, 3450.17, 3462.29, 3461.4, 3458.89, 3471.12, 3489.42, 3483.44, 3468.24, 3468.46, 3469.83, 3449.41, 3439.28, 3424.16, 3434.88, 3436.84, 3427.32, 3429.88, 3424.34, 3430.57, 3442.3, 3440.31, 3441.77, 3435.31, 3433.05, 3438.2, 3428.57, 3417.64, 3409.63, 3399.85, 3383.54, 3391.32, 3385.85, 3385.89, 3387.85, 3388.98, 3373.22, 3358.94, 3357.09, 3386.9, 3384.09, 3372.37, 3373.48, 3361.6, 3339.28, 3332.91, 3340.01, 3335.48, 3320.36, 3325.41, 3311.22, 3305.8, 3338.05, 3346.76, 3348.42, 3352.2, 3355.57, 3364.54, 3375.25, 3372.17, 3363.38, 3368.91, 3372.81, 3367.92, 3371.89, 3367.42, 3378.52, 3375.49, 3365.52, 3370.61, 3372.0, 3364.61, 3356.57, 3357.74, 3336.43, 3324.6, 3312.54, 3311.18, 3283.14, 3282.29, 3285.46, 3270.19, 3275.01, 3262.43, 3256.04, 3265.88, 3272.57, 3285.33, 3275.16, 3282.24, 3278.44, 3275.82, 3273.23, 3268.84, 3254.27, 3258.28, 3283.59, 3282.14, 3284.54, 3280.34, 3298.03, 3309.88, 3316.77, 3311.46, 3316.98, 3316.96, 3306.81, 3319.26, 3313.03, 3307.81, 3314.7, 3309.17, 3316.16, 3350.84, 3357.5, 3344.15, 3343.86, 3333.36, 3352.39, 3356.34, 3361.51, 3360.9, 3362.72, 3369.3, 3364.63, 3364.22, 3369.12, 3358.34, 3366.41, 3372.68, 3371.72, 3366.79, 3386.62, 3382.17, 3376.58, 3374.72, 3382.22, 3388.02, 3382.69, 3380.87, 3382.33, 3365.13, 3369.43, 3363.23, 3374.92, 3375.62, 3373.96, 3377.05, 3370.06, 3368.86, 3376.88, 3377.53, 3405.19, 3418.26, 3411.12, 3405.85, 3410.27, 3409.95, 3411.13, 3425.4, 3426.65, 3417.37, 3400.16, 3399.76, 3398.29, 3406.45, 3494.87, 3467.63, 3462.98, 3456.18, 3460.24, 3446.53, 3441.31, 3436.48, 3433.06, 3437.69, 3437.81, 3435.78, 3430.82, 3430.55, 3435.01, 3433.38, 3436.67, 3443.62, 3438.54, 3454.89, 3460.84, 3458.17, 3464.12, 3461.52, 3442.93, 3419.87, 3419.38, 3415.59, 3417.1, 3425.83, 3424.91, 3408.34, 3401.93, 3397.01, 3397.91, 3395.61, 3400.16, 3392.74, 3393.6, 3386.4, 3393.63, 3396.21, 3383.75, 3377.14, 3381.32, 3389.3, 3375.09, 3368.07, 3392.9, 3393.59, 3389.72, 3385.64, 3396.46, 3395.54, 3388.17, 3385.35, 3374.18, 3367.05, 3363.37, 3361.21, 3371.57, 3377.09, 3377.53, 3376.99, 3379.33, 3380.96, 3383.09, 3388.74, 3390.62, 3376.96, 3371.02, 3372.38, 3384.99, 3372.4, 3381.97, 3383.8, 3378.16, 3380.74, 3364.04, 3359.95, 3369.95, 3380.34, 3379.45, 3380.05, 3383.78, 3383.3, 3383.79, 3394.9, 3406.21, 3397.13, 3396.75, 3387.02, 3390.63, 3397.0, 3397.58, 3393.35, 3393.24, 3395.49, 3397.79, 3398.28, 3401.1, 3396.76, 3399.18, 3400.66, 3403.34, 3397.7, 3401.89, 3418.95, 3412.05, 3411.23, 3404.71, 3405.83, 3412.84, 3409.49, 3408.73, 3408.77, 3403.95, 3405.5, 3410.86, 3411.99, 3413.45, 3405.33, 3404.87, 3393.69, 3396.41, 3383.12, 3379.02, 3375.37, 3351.72, 3332.56, 3330.15, 3327.6, 3316.43, 3300.28, 3284.84, 3271.58, 3273.57, 3266.48, 3269.06, 3257.71, 3247.66, 3251.33, 3232.4, 3225.98, 3211.29, 3219.12, 3218.88, 3219.49, 3210.06, 3195.79, 3209.46, 3208.16, 3213.34, 3212.28, 3207.2, 3200.7, 3209.29, 3217.25, 3226.89, 3230.85, 3228.16, 3228.81, 3219.12, 3203.07, 3193.12, 3233.76, 3246.29, 3233.52, 3224.49, 3227.63, 3224.69, 3228.97, 3226.33, 3224.87, 3220.49, 3222.43, 3220.11, 3206.12, 3215.1, 3207.09, 3202.28, 3201.82, 3196.0, 3185.21],[2857.72, 2866.24, 2870.19, 2872.03, 2875.13, 2877.38, 2869.67, 2869.15, 2855.82, 2850.87, 2857.35, 2869.91, 2872.87, 2869.98, 2869.92, 2868.7, 2876.51, 2874.28, 2876.24, 2872.74, 2866.52, 2867.87, 2864.52, 2862.19, 2853.1, 2857.2, 2861.93, 2859.92, 2859.58, 2856.07, 2854.41, 2851.3, 2855.39, 2852.71, 2854.78, 2855.67, 2851.08, 2852.73, 2845.31, 2850.83, 2856.07, 2853.54, 2854.88, 2856.11, 2853.91, 2852.37, 2850.4, 2850.48, 2839.39, 2857.6, 2876.63, 2878.16, 2871.2, 2865.71, 2864.44, 2868.5, 2873.06, 2881.02, 2878.5, 2877.79, 2874.08, 2875.59, 2874.26, 2874.05, 2877.77, 2895.58, 2892.12, 2892.82, 2888.93, 2889.74, 2891.43, 2892.03, 2879.75, 2867.85, 2866.72, 2864.55, 2859.84, 2855.33, 2858.2, 2860.76, 2848.15, 2852.11, 2853.45, 2853.89, 2852.6, 2853.94, 2855.41, 2855.05, 2851.76, 2849.41, 2849.33, 2851.13, 2849.4, 2849.36, 2845.5, 2845.68, 2844.48, 2841.23, 2839.34, 2839.93, 2845.14, 2844.55, 2845.53, 2849.29, 2847.39, 2845.69, 2845.28, 2845.68, 2845.4, 2845.05, 2844.38, 2851.31, 2847.27, 2847.44, 2847.58, 2843.98, 2843.16, 2845.29, 2845.59, 2845.09, 2843.36, 2837.95, 2835.87, 2840.98, 2833.92, 2830.96, 2831.71, 2834.66, 2822.9, 2815.38, 2819.33, 2817.98, 2821.19, 2825.02, 2825.4, 2823.11, 2817.01, 2826.94, 2836.06, 2855.64, 2853.93, 2860.26, 2851.45, 2842.21, 2826.48, 2823.52, 2822.57, 2822.5, 2821.14, 2823.08, 2816.86, 2810.37, 2805.83, 2800.86, 2799.38, 2795.4, 2794.91, 2797.27, 2797.01, 2800.52, 2784.16, 2781.94, 2787.11, 2789.15, 2781.95, 2784.56, 2784.43, 2783.88, 2782.1, 2780.74, 2785.1, 2782.09, 2781.14, 2779.43, 2777.47, 2783.55, 2788.69, 2795.65, 2792.87, 2780.97, 2778.6, 2774.54, 2771.97, 2765.64, 2742.76, 2738.93, 2736.0, 2735.92, 2737.31, 2729.59, 2726.97, 2730.54, 2729.97, 2724.38, 2727.12, 2718.63, 2722.07, 2722.84, 2730.27, 2738.79, 2720.91, 2719.68, 2720.42, 2717.83, 2715.69, 2713.89, 2710.62, 2716.39, 2722.14, 2721.12, 2718.41, 2717.79, 2719.65, 2724.29, 2720.56, 2716.56, 2717.41, 2719.44, 2712.89, 2711.99, 2713.02, 2712.19, 2707.64, 2703.37, 2700.78, 2703.26, 2702.85, 2701.7, 2689.7, 2696.48, 2713.9, 2713.26, 2697.78, 2705.91, 2733.12, 2725.76, 2732.9, 2731.2, 2729.09, 2732.78, 2726.5, 2724.01, 2730.36, 2728.91, 2720.0, 2717.95, 2720.35, 2726.23, 2731.36, 2740.22, 2746.06, 2753.35, 2751.5, 2748.55, 2746.17, 2747.19, 2766.24, 2761.37, 2766.27, 2788.92, 2815.23, 2844.66, 2843.25, 2850.01, 2901.42, 2933.82, 2927.06, 2907.37, 2907.54, 2889.05, 2895.98, 2893.17, 2889.01, 2907.21, 2911.17, 2910.69, 2914.52, 2948.6, 2961.08, 2975.8, 3017.45, 3027.01, 3030.58, 3030.14, 3064.91, 3075.64, 3073.62, 3075.51, 3153.7, 3186.24, 3208.88, 3238.38, 3263.88, 3296.84, 3282.3, 3295.92, 3518.6, 3474.08, 3372.19, 3436.95, 3450.64, 3420.35, 3438.12, 3471.51, 3323.96, 3344.17, 3295.15, 3249.16, 3305.3, 3341.73, 3309.99, 3258.86, 3257.99, 3228.12, 3273.15, 3314.83, 3340.45, 3329.3, 3303.22, 3300.25, 3257.28, 3237.61, 3239.3, 3246.73, 3236.03, 3226.27, 3202.69, 3187.99, 3220.37, 3203.9, 3208.63, 3227.96, 3264.46, 3266.52, 3257.54, 3267.03, 3234.59, 3266.35, 3256.18, 3252.25, 3239.21, 3235.53, 3216.39, 3201.29, 3167.74, 3182.18, 3183.2, 3207.32, 3200.5, 3196.0, 3186.31, 3197.08, 3210.7, 3202.47, 3193.65, 3198.69, 3201.98, 3195.13, 3173.25, 3169.38, 3159.8, 3152.82, 3175.92, 3183.37, 3191.53, 3224.97, 3251.15, 3259.47, 3239.1, 3243.19, 3265.69, 3265.43, 3269.32, 3259.63, 3256.45, 3262.05, 3255.14, 3270.02, 3266.45, 3270.7, 3272.56, 3258.97, 3267.72, 3275.12, 3277.07, 3288.03, 3298.02, 3300.87, 3311.11, 3308.48, 3292.69, 3293.59, 3275.76, 3274.61, 3276.81, 3280.21, 3269.81, 3266.88, 3269.2, 3274.77, 3277.77, 3276.13, 3283.66, 3288.77, 3303.73, 3296.37, 3289.42, 3292.51, 3279.72, 3293.55, 3303.47, 3295.62, 3299.92, 3305.14, 3304.24, 3310.03, 3313.8, 3312.01, 3320.34, 3300.33, 3289.8, 3287.77, 3286.55, 3284.21, 3273.64, 3276.14, 3270.77, 3257.54, 3244.81, 3248.38, 3246.98, 3261.04, 3252.39, 3257.49, 3276.68, 3275.23, 3267.99, 3262.62, 3275.18, 3272.84, 3267.74, 3258.73, 3286.36, 3287.92, 3283.98, 3277.27, 3275.28, 3271.27, 3263.84, 3274.15, 3277.77, 3281.73, 3279.38, 3279.74, 3287.5, 3294.99, 3302.05, 3331.06, 3340.5, 3346.1, 3370.4, 3370.45, 3365.39, 3379.88, 3376.32, 3398.1, 3391.66, 3368.89, 3377.43, 3378.27, 3390.27, 3367.08, 3356.26, 3388.4, 3388.36, 3404.91, 3413.11, 3416.09, 3436.6, 3448.05, 3472.52, 3482.07, 3464.54, 3451.5, 3448.1, 3464.72, 3449.47, 3443.19, 3428.77, 3423.24, 3416.73, 3435.48, 3447.29, 3448.74, 3445.5, 3457.57, 3459.9, 3465.33, 3457.1, 3452.89, 3444.56, 3429.76, 3411.43, 3402.04, 3406.78, 3411.17, 3404.53, 3420.18, 3412.35, 3409.36, 3428.15, 3426.92, 3422.94, 3423.87, 3419.06, 3424.63, 3411.02, 3406.64, 3389.79, 3376.15, 3358.71, 3373.23, 3372.18, 3360.61, 3365.7, 3373.04, 3351.95, 3330.73, 3319.48, 3339.04, 3364.65, 3358.64, 3360.1, 3336.28, 3316.0, 3309.01, 3317.74, 3310.17, 3305.78, 3308.63, 3301.45, 3284.13, 3300.94, 3328.3, 3333.0, 3338.65, 3340.96, 3354.01, 3357.25, 3353.85, 3350.51, 3359.8, 3359.56, 3356.03, 3362.02, 3360.16, 3361.64, 3363.41, 3348.86, 3361.46, 3358.76, 3349.97, 3345.08, 3336.71, 3311.2, 3310.47, 3298.99, 3267.19, 3256.76, 3259.37, 3267.99, 3255.09, 3252.29, 3244.22, 3232.92, 3243.53, 3252.87, 3264.8, 3263.8, 3265.25, 3264.75, 3256.85, 3256.39, 3257.26, 3234.81, 3227.36, 3250.81, 3266.42, 3269.8, 3268.44, 3273.18, 3295.66, 3301.09, 3301.55, 3306.43, 3293.34, 3299.31, 3304.85, 3304.68, 3290.36, 3294.42, 3293.69, 3297.14, 3315.56, 3336.63, 3333.6, 3318.78, 3323.51, 3323.01, 3343.85, 3347.74, 3346.66, 3350.9, 3358.82, 3352.28, 3350.03, 3352.69, 3348.37, 3352.07, 3360.69, 3361.35, 3352.41, 3366.71, 3375.65, 3362.4, 3365.6, 3370.88, 3374.47, 3374.83, 3372.2, 3353.84, 3352.94, 3353.06, 3353.5, 3359.39, 3363.03, 3365.03, 3367.41, 3357.3, 3360.01, 3364.21, 3365.5, 3376.42, 3401.06, 3399.83, 3396.77, 3403.12, 3402.58, 3397.98, 3406.02, 3414.09, 3390.62, 3385.96, 3386.03, 3390.38, 3397.37, 3446.79, 3447.7, 3445.99, 3440.36, 3443.48, 3437.1, 3427.77, 3417.77, 3416.09, 3425.1, 3429.16, 3421.66, 3424.48, 3420.16, 3425.98, 3428.52, 3427.45, 3433.49, 3425.98, 3428.45, 3446.52, 3449.45, 3451.7, 3456.1, 3419.69, 3407.31, 3405.74, 3406.5, 3403.53, 3405.72, 3407.17, 3390.75, 3388.8, 3386.34, 3385.02, 3389.24, 3388.49, 3386.36, 3380.64, 3376.54, 3376.02, 3382.34, 3368.4, 3365.53, 3359.43, 3374.78, 3363.26, 3357.77, 3371.3, 3381.51, 3380.49, 3378.16, 3383.48, 3384.26, 3381.34, 3375.78, 3346.47, 3353.58, 3352.68, 3355.47, 3353.26, 3367.43, 3364.09, 3366.7, 3362.82, 3371.68, 3373.23, 3380.95, 3375.47, 3369.8, 3362.85, 3365.1, 3367.56, 3361.83, 3368.98, 3371.01, 3366.28, 3363.08, 3348.28, 3350.17, 3352.95, 3367.49, 3362.59, 3368.23, 3367.83, 3377.54, 3376.16, 3383.05, 3386.08, 3386.07, 3384.41, 3374.01, 3377.92, 3388.69, 3386.97, 3381.9, 3380.25, 3384.25, 3389.86, 3392.78, 3394.17, 3390.83, 3390.9, 3395.31, 3392.8, 3388.32, 3393.91, 3399.02, 3405.98, 3402.3, 3393.17, 3397.42, 3395.4, 3403.78, 3401.77, 3394.96, 3395.75, 3400.3, 3404.7, 3403.59, 3402.23, 3398.26, 3389.76, 3373.77, 3380.76, 3373.83, 3355.43, 3351.76, 3330.27, 3310.86, 3316.14, 3314.85, 3292.57, 3273.29, 3255.39, 3242.09, 3243.34, 3237.66, 3248.47, 3247.32, 3233.85, 3226.97, 3205.78, 3207.25, 3191.54, 3185.97, 3203.0, 3198.35, 3191.86, 3185.46, 3191.42, 3188.69, 3194.4, 3202.09, 3190.46, 3190.5, 3191.17, 3204.13, 3204.78, 3220.32, 3213.56, 3214.24, 3201.13, 3180.93, 3175.72, 3188.03, 3226.17, 3218.14, 3209.64, 3213.81, 3217.28, 3218.14, 3218.12, 3213.22, 3205.91, 3211.39, 3198.49, 3192.54, 3201.35, 3197.22, 3190.23, 3193.66, 3182.27, 3168.52]);
    
    let zigzag = market.zigzag_with_flag(false);
    println!("Zigzag: {:?}", zigzag);
}